package preprocess.similarity;

import common.Word;
import java.util.ArrayList;
public class SimRecord{
    private Word keyword;
    public ArrayList<SimItem> colist = new ArrayList<SimItem>();	// correlate keywords list

    public SimRecord( String keyword ){
        this.keyword.setKeyword( keyword );
    }

    public SimRecord( Word keyword ){
        this.keyword = keyword;
    }

    public Word getKeyword(){
	    return this.keyword;
    }
    
    public int numSimWords(){
	    return colist.size();
    }
    public String toString(){
        String str = keyword.getKeyword()+","+String.valueOf(keyword.getWeight())+","+colist.toString();
        return str;
    }

    /**
     * add a similarity word 
     * @param word is the keyword
     * @param sim is similarity rate between two words
     */
    public void addSimWord( String word,float sim ){
        //this.weight += sim;
        SimItem item = new SimItem( word,sim );
        this.colist.add( item );
    }

    /**
     * extract keywords from a record
     */
    public ArrayList<Word> extractWords(){
        ArrayList<Word> words = new ArrayList<Word>();
        for( int i=0;i<colist.size();i++ ){
            words.add( new Word(colist.get(i).keyword,colist.get(i).rate) );
        }
        return words;
    }
}